package util;


import entry.User;
import java.util.ArrayList;

public class PageHelper {
    private Integer showData = 5;//每页显示几条数据
    private Integer countData;//一共有多少条数据 查数据库
    private Integer countPage;//一共能分多少页
    private Integer indexPage = 1;//当前是第几页 默认当前是第一页
    private ArrayList<User> list;//当前页显示的集合数据

    public PageHelper(Integer showData, Integer countData, Integer countPage, Integer indexPage, ArrayList<User> list) {
        this.showData = showData;
        this.countData = countData;
        this.countPage = countPage;
        this.indexPage = indexPage;
        this.list = list;
    }

    public PageHelper() {
    }

    public Integer getShowData() {
        return showData;
    }

    public void setShowData(Integer showData) {
        this.showData = showData;
    }

    public Integer getCountData() {
        return countData;
    }

    public void setCountData(Integer countData) {
        this.countData = countData;
        //当给总条数赋值后，立刻就知道总页数
        getCountPage();
    }

    public Integer getCountPage() {
        countPage = countData % showData == 0 ? countData / showData : countData / showData + 1;
        return countPage;
    }

    /*public void setCountPage(Integer countPage) {
        this.countPage = countPage;
    }*/

    public Integer getIndexPage() {
        return indexPage;
    }

    public void setIndexPage(Integer indexPage) {
        this.indexPage = indexPage;
    }

    public ArrayList<User> getList() {
        return list;
    }

    public void setList(ArrayList<User> list) {
        this.list = list;
    }
}
